<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('模具基本信息填写')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <mold-basic-information-modal ref="modalForm" @ok="modalFormOk"></mold-basic-information-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import MoldBasicInformationModal from './modules/MoldBasicInformationModal'

  export default {
    name: 'MoldBasicInformationList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      MoldBasicInformationModal
    },
    data () {
      return {
        description: '模具基本信息填写管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'CHT模号',
            align:"center",
            dataIndex: 'chtMoldNum'
          },
          {
            title:'螺杆种类',
            align:"center",
            dataIndex: 'screwType'
          },
          {
            title:'建议螺杆直径',
            align:"center",
            dataIndex: 'suggestedMachineScrewDiameter'
          },
          {
            title:'射速需求',
            align:"center",
            dataIndex: 'requiredInjectionRate'
          },
          {
            title:'每模塑化的时间',
            align:"center",
            dataIndex: 'timePerMolding'
          },
          {
            title:'前模运水流动速率',
            align:"center",
            dataIndex: 'cavityCicuitFlowRate'
          },
          {
            title:'后模运水流动速率',
            align:"center",
            dataIndex: 'coreCicuitFlowRate'
          },
          {
            title:'浇口形式',
            align:"center",
            dataIndex: 'gateType'
          },
          {
            title:'流道种类',
            align:"center",
            dataIndex: 'runnerType'
          },
          {
            title:'顶出方案',
            align:"center",
            dataIndex: 'ejectorScheme'
          },
          {
            title:'热流道品牌',
            align:"center",
            dataIndex: 'hotRunnerBrand'
          },
          {
            title:'热咀数量',
            align:"center",
            dataIndex: 'numberOfHotNozzle'
          },
          {
            title:'热咀形式',
            align:"center",
            dataIndex: 'hotNozzleType'
          },
          {
            title:'达到顶出温度时间',
            align:"center",
            dataIndex: 'timeToReachEjectionTemp'
          },
          {
            title:'开合模时间',
            align:"center",
            dataIndex: 'openingAndClosingDieTime'
          },
          {
            title:'取产品时间',
            align:"center",
            dataIndex: 'productPickUpTime'
          },
          {
            title:'模胚尺寸',
            align:"center",
            dataIndex: 'moldBaseSize'
          },
          {
            title:'模具种类',
            align:"center",
            dataIndex: 'moldBaseType'
          },
          {
            title:'机械手种类',
            align:"center",
            dataIndex: 'manipulatorType'
          },
          {
            title:'模具温控箱',
            align:"center",
            dataIndex: 'tempControlBox'
          },
          {
            title:'模温机',
            align:"center",
            dataIndex: 'moldTemperatureMachine'
          },
          {
            title:'手掌(EOAT）',
            align:"center",
            dataIndex: 'eoat'
          },
          {
            title:'成型机台型号',
            align:"center",
            dataIndex: 'moldingMachineModel'
          },
          {
            title:'成型吨位',
            align:"center",
            dataIndex: 'machineTonnage'
          },
          {
            title:'注塑机容模尺寸（长宽高）',
            align:"center",
            dataIndex: 'injectionMoldingMachineSize'
          },
          {
            title:'成型周期',
            align:"center",
            dataIndex: 'moldingCycle'
          },
          {
            title:'穴数',
            align:"center",
            dataIndex: 'cavities'
          },
          {
            title:'模具难度',
            align:"center",
            dataIndex: 'moldDifficulty'
          },
          {
            title:'流道重量/穴',
            align:"center",
            dataIndex: 'runnerWeight'
          },
          {
            title:'流道总重量',
            align:"center",
            dataIndex: 'runnerTotalWeight'
          },
          {
            title:'产品单重/穴',
            align:"center",
            dataIndex: 'partWeight'
          },
          {
            title:'总重量/模',
            align:"center",
            dataIndex: 'oneShotTotalWeight'
          },
          {
            title:'炮筒最大射出量',
            align:"center",
            dataIndex: 'maxVolumeOfBarrelShot'
          },
          {
            title:'射胶量百分比',
            align:"center",
            dataIndex: 'injectionPercentage'
          },
          {
            title:'料筒停留时间',
            align:"center",
            dataIndex: 'barrelResidenceTime'
          },
          {
            title:'模具寿命',
            align:"center",
            dataIndex: 'moldLife'
          },
          {
            title:'热嘴套钢料',
            align:"center",
            dataIndex: 'hotNozzleSleeveSteel'
          },
          {
            title:'前模芯钢料',
            align:"center",
            dataIndex: 'cavitySteel'
          },
          {
            title:'推套钢料',
            align:"center",
            dataIndex: 'pushRingSteel'
          },
          {
            title:'后模芯钢料',
            align:"center",
            dataIndex: 'coreSteel'
          },
          {
            title:'模胚形式',
            align:"center",
            dataIndex: 'moldType'
          },
          {
            title:'其他配件',
            align:"center",
            dataIndex: 'others'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/ch/moldBasicInformation/list",
          delete: "/ch/moldBasicInformation/delete",
          deleteBatch: "/ch/moldBasicInformation/deleteBatch",
          exportXlsUrl: "/ch/moldBasicInformation/exportXls",
          importExcelUrl: "ch/moldBasicInformation/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'chtMoldNum',text:'CHT模号',dictCode:''})
        fieldList.push({type:'string',value:'screwType',text:'螺杆种类',dictCode:''})
        fieldList.push({type:'string',value:'suggestedMachineScrewDiameter',text:'建议螺杆直径',dictCode:''})
        fieldList.push({type:'string',value:'requiredInjectionRate',text:'射速需求',dictCode:''})
        fieldList.push({type:'string',value:'timePerMolding',text:'每模塑化的时间',dictCode:''})
        fieldList.push({type:'string',value:'cavityCicuitFlowRate',text:'前模运水流动速率',dictCode:''})
        fieldList.push({type:'string',value:'coreCicuitFlowRate',text:'后模运水流动速率',dictCode:''})
        fieldList.push({type:'string',value:'gateType',text:'浇口形式',dictCode:''})
        fieldList.push({type:'string',value:'runnerType',text:'流道种类',dictCode:''})
        fieldList.push({type:'string',value:'ejectorScheme',text:'顶出方案',dictCode:''})
        fieldList.push({type:'string',value:'hotRunnerBrand',text:'热流道品牌',dictCode:''})
        fieldList.push({type:'string',value:'numberOfHotNozzle',text:'热咀数量',dictCode:''})
        fieldList.push({type:'string',value:'hotNozzleType',text:'热咀形式',dictCode:''})
        fieldList.push({type:'string',value:'timeToReachEjectionTemp',text:'达到顶出温度时间',dictCode:''})
        fieldList.push({type:'string',value:'openingAndClosingDieTime',text:'开合模时间',dictCode:''})
        fieldList.push({type:'string',value:'productPickUpTime',text:'取产品时间',dictCode:''})
        fieldList.push({type:'string',value:'moldBaseSize',text:'模胚尺寸',dictCode:''})
        fieldList.push({type:'string',value:'moldBaseType',text:'模具种类',dictCode:''})
        fieldList.push({type:'string',value:'manipulatorType',text:'机械手种类',dictCode:''})
        fieldList.push({type:'string',value:'tempControlBox',text:'模具温控箱',dictCode:''})
        fieldList.push({type:'string',value:'moldTemperatureMachine',text:'模温机',dictCode:''})
        fieldList.push({type:'string',value:'eoat',text:'手掌(EOAT）',dictCode:''})
        fieldList.push({type:'string',value:'moldingMachineModel',text:'成型机台型号',dictCode:''})
        fieldList.push({type:'string',value:'machineTonnage',text:'成型吨位',dictCode:''})
        fieldList.push({type:'string',value:'injectionMoldingMachineSize',text:'注塑机容模尺寸（长宽高）',dictCode:''})
        fieldList.push({type:'string',value:'moldingCycle',text:'成型周期',dictCode:''})
        fieldList.push({type:'string',value:'cavities',text:'穴数',dictCode:''})
        fieldList.push({type:'string',value:'moldDifficulty',text:'模具难度',dictCode:''})
        fieldList.push({type:'string',value:'runnerWeight',text:'流道重量/穴',dictCode:''})
        fieldList.push({type:'string',value:'runnerTotalWeight',text:'流道总重量',dictCode:''})
        fieldList.push({type:'string',value:'partWeight',text:'产品单重/穴',dictCode:''})
        fieldList.push({type:'string',value:'oneShotTotalWeight',text:'总重量/模',dictCode:''})
        fieldList.push({type:'string',value:'maxVolumeOfBarrelShot',text:'炮筒最大射出量',dictCode:''})
        fieldList.push({type:'string',value:'injectionPercentage',text:'射胶量百分比',dictCode:''})
        fieldList.push({type:'string',value:'barrelResidenceTime',text:'料筒停留时间',dictCode:''})
        fieldList.push({type:'string',value:'moldLife',text:'模具寿命',dictCode:''})
        fieldList.push({type:'string',value:'hotNozzleSleeveSteel',text:'热嘴套钢料',dictCode:''})
        fieldList.push({type:'string',value:'cavitySteel',text:'前模芯钢料',dictCode:''})
        fieldList.push({type:'string',value:'pushRingSteel',text:'推套钢料',dictCode:''})
        fieldList.push({type:'string',value:'coreSteel',text:'后模芯钢料',dictCode:''})
        fieldList.push({type:'string',value:'moldType',text:'模胚形式',dictCode:''})
        fieldList.push({type:'string',value:'others',text:'其他配件',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>